﻿using System;
using System.Collections.Generic;
using System.Linq;
using Helpers;
using TaleWorlds.CampaignSystem.Actions;
using TaleWorlds.CampaignSystem.AgentOrigins;
using TaleWorlds.CampaignSystem.Conversation;
using TaleWorlds.CampaignSystem.Encounters;
using TaleWorlds.CampaignSystem.Extensions;
using TaleWorlds.CampaignSystem.GameState;
using TaleWorlds.CampaignSystem.MapEvents;
using TaleWorlds.CampaignSystem.Party;
using TaleWorlds.CampaignSystem.Roster;
using TaleWorlds.CampaignSystem.Settlements;
using TaleWorlds.CampaignSystem.Settlements.Locations;
using TaleWorlds.Core;
using TaleWorlds.Library;
using TaleWorlds.Localization;
using TaleWorlds.SaveSystem;

namespace TaleWorlds.CampaignSystem.Issues
{
	// Token: 0x02000314 RID: 788
	public class LordsNeedsTutorIssueBehavior : CampaignBehaviorBase
	{
		// Token: 0x06002D7A RID: 11642 RVA: 0x000BE5BC File Offset: 0x000BC7BC
		public override void RegisterEvents()
		{
			CampaignEvents.OnCheckForIssueEvent.AddNonSerializedListener(this, new Action<Hero>(this.OnCheckForIssue));
		}

		// Token: 0x06002D7B RID: 11643 RVA: 0x000BE5D8 File Offset: 0x000BC7D8
		public void OnCheckForIssue(Hero hero)
		{
			Hero relatedObject;
			if (this.ConditionsHold(hero, out relatedObject))
			{
				Campaign.Current.IssueManager.AddPotentialIssueData(hero, new PotentialIssueData(new PotentialIssueData.StartIssueDelegate(this.OnStartIssue), typeof(LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssue), IssueBase.IssueFrequency.Common, relatedObject));
				return;
			}
			Campaign.Current.IssueManager.AddPotentialIssueData(hero, new PotentialIssueData(typeof(LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssue), IssueBase.IssueFrequency.Common));
		}

		// Token: 0x06002D7C RID: 11644 RVA: 0x000BE640 File Offset: 0x000BC840
		private bool SuitableCondition(Hero hero)
		{
			return hero.Age >= 18f && hero.Age < 23f && hero.PartyBelongedTo == null && hero.PartyBelongedToAsPrisoner == null && hero.IsActive && hero.CurrentSettlement != null && hero.Level <= 15 && !hero.IsFemale && hero.Clan != Clan.PlayerClan && !LordsNeedsTutorIssueBehavior._alreadyChosenHeroes.Contains(hero);
		}

		// Token: 0x06002D7D RID: 11645 RVA: 0x000BE6B8 File Offset: 0x000BC8B8
		private bool ConditionsHold(Hero issueGiver, out Hero youngHero)
		{
			youngHero = null;
			if (issueGiver.IsLord && issueGiver.Clan != Clan.PlayerClan && issueGiver.Age > 30f && !issueGiver.IsMinorFactionHero)
			{
				youngHero = issueGiver.Clan.Lords.FirstOrDefault(new Func<Hero, bool>(this.SuitableCondition));
				if (youngHero != null && youngHero != issueGiver && !this.SuitableCondition(issueGiver))
				{
					return true;
				}
			}
			return false;
		}

		// Token: 0x06002D7E RID: 11646 RVA: 0x000BE728 File Offset: 0x000BC928
		private IssueBase OnStartIssue(in PotentialIssueData pid, Hero issueOwner)
		{
			PotentialIssueData potentialIssueData = pid;
			return new LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssue(issueOwner, potentialIssueData.RelatedObject as Hero);
		}

		// Token: 0x06002D7F RID: 11647 RVA: 0x000BE74E File Offset: 0x000BC94E
		public override void SyncData(IDataStore dataStore)
		{
			dataStore.SyncData<List<Hero>>("_alreadyChosenHeroes", ref LordsNeedsTutorIssueBehavior._alreadyChosenHeroes);
		}

		// Token: 0x06002D80 RID: 11648 RVA: 0x000BE761 File Offset: 0x000BC961
		private static void SetAlreadyChosenHero(Hero hero)
		{
			if (LordsNeedsTutorIssueBehavior._alreadyChosenHeroes == null)
			{
				LordsNeedsTutorIssueBehavior._alreadyChosenHeroes = new List<Hero>
				{
					hero
				};
				return;
			}
			if (!LordsNeedsTutorIssueBehavior._alreadyChosenHeroes.Contains(hero))
			{
				LordsNeedsTutorIssueBehavior._alreadyChosenHeroes.Add(hero);
			}
		}

		// Token: 0x04000D9A RID: 3482
		private const int YoungHeroAgeMinValue = 18;

		// Token: 0x04000D9B RID: 3483
		private const int YoungHeroAgeMaxValue = 23;

		// Token: 0x04000D9C RID: 3484
		private const IssueBase.IssueFrequency LordsNeedsTutorIssueFrequency = IssueBase.IssueFrequency.Common;

		// Token: 0x04000D9D RID: 3485
		private const int QuestDurationInDays = 200;

		// Token: 0x04000D9E RID: 3486
		private static List<Hero> _alreadyChosenHeroes = new List<Hero>();

		// Token: 0x02000650 RID: 1616
		public class LordsNeedsTutorIssue : IssueBase
		{
			// Token: 0x06005098 RID: 20632 RVA: 0x0016F368 File Offset: 0x0016D568
			internal static void AutoGeneratedStaticCollectObjectsLordsNeedsTutorIssue(object o, List<object> collectedObjects)
			{
				((LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssue)o).AutoGeneratedInstanceCollectObjects(collectedObjects);
			}

			// Token: 0x06005099 RID: 20633 RVA: 0x0016F376 File Offset: 0x0016D576
			protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
			{
				base.AutoGeneratedInstanceCollectObjects(collectedObjects);
				collectedObjects.Add(this._youngHero);
			}

			// Token: 0x0600509A RID: 20634 RVA: 0x0016F38B File Offset: 0x0016D58B
			internal static object AutoGeneratedGetMemberValue_youngHero(object o)
			{
				return ((LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssue)o)._youngHero;
			}

			// Token: 0x170010EB RID: 4331
			// (get) Token: 0x0600509B RID: 20635 RVA: 0x0016F398 File Offset: 0x0016D598
			public override bool IsThereAlternativeSolution
			{
				get
				{
					return false;
				}
			}

			// Token: 0x170010EC RID: 4332
			// (get) Token: 0x0600509C RID: 20636 RVA: 0x0016F39B File Offset: 0x0016D59B
			public override bool IsThereLordSolution
			{
				get
				{
					return false;
				}
			}

			// Token: 0x170010ED RID: 4333
			// (get) Token: 0x0600509D RID: 20637 RVA: 0x0016F39E File Offset: 0x0016D59E
			public override TextObject IssueBriefByIssueGiver
			{
				get
				{
					TextObject textObject = new TextObject("{=VtSg9OYK}I've heard good things about you. They say that you are an accomplished warrior. [if:convo_thinking][ib:closed]Some also say an accomplished commander. I have a proposal for you. There is a young lord from my clan. He is an aspiring warrior and I must say he quite admires you. He wants to learn from you. What do you say? Are you willing to take him under your wings for a while? Let's say {QUEST_DURATION} days?", null);
					textObject.SetTextVariable("QUEST_DURATION", 200);
					return textObject;
				}
			}

			// Token: 0x170010EE RID: 4334
			// (get) Token: 0x0600509E RID: 20638 RVA: 0x0016F3BC File Offset: 0x0016D5BC
			public override TextObject IssueAcceptByPlayer
			{
				get
				{
					return new TextObject("{=a1n2zCaD}What exactly do you wish from me?", null);
				}
			}

			// Token: 0x170010EF RID: 4335
			// (get) Token: 0x0600509F RID: 20639 RVA: 0x0016F3C9 File Offset: 0x0016D5C9
			public override TextObject IssueQuestSolutionExplanationByIssueGiver
			{
				get
				{
					return new TextObject("{=JlFfuFEC}How about you take him with you? [if:convo_merry][ib:confident3]Feed and protect him, sure, but don't treat him any differently from your companions. Let him stay with you for a year, and then let him return to us? I will send you a worthwhile gift and, perhaps more valuably, you will gain my lifelong friendship, assuming everything goes well?", null);
				}
			}

			// Token: 0x170010F0 RID: 4336
			// (get) Token: 0x060050A0 RID: 20640 RVA: 0x0016F3D6 File Offset: 0x0016D5D6
			public override TextObject IssueQuestSolutionAcceptByPlayer
			{
				get
				{
					return new TextObject("{=iTYoUNdC}All right. I'll take him with me.", null);
				}
			}

			// Token: 0x170010F1 RID: 4337
			// (get) Token: 0x060050A1 RID: 20641 RVA: 0x0016F3E4 File Offset: 0x0016D5E4
			public override TextObject Title
			{
				get
				{
					TextObject textObject = new TextObject("{=XmGjTZz0}{?QUEST_GIVER.GENDER}Lady{?}Lord{\\?} Needs A Tutor", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.IssueOwner.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x170010F2 RID: 4338
			// (get) Token: 0x060050A2 RID: 20642 RVA: 0x0016F418 File Offset: 0x0016D618
			public override TextObject Description
			{
				get
				{
					TextObject textObject = new TextObject("{=MSr3HRa1}{QUEST_GIVER.NAME}, a {?QUEST_GIVER.GENDER}lady{?}lord{\\?} of the {CLAN}, wants young member of the clan trained in the arts of war.", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.IssueOwner.CharacterObject, textObject, false);
					textObject.SetTextVariable("CLAN", base.IssueOwner.Clan.Name);
					return textObject;
				}
			}

			// Token: 0x060050A3 RID: 20643 RVA: 0x0016F466 File Offset: 0x0016D666
			public LordsNeedsTutorIssue(Hero issueOwner, Hero youngHero) : base(issueOwner, CampaignTime.DaysFromNow(200f))
			{
				this._youngHero = youngHero;
			}

			// Token: 0x060050A4 RID: 20644 RVA: 0x0016F480 File Offset: 0x0016D680
			protected override float GetIssueEffectAmountInternal(IssueEffect issueEffect)
			{
				if (issueEffect == DefaultIssueEffects.ClanInfluence)
				{
					return -0.1f;
				}
				return 0f;
			}

			// Token: 0x060050A5 RID: 20645 RVA: 0x0016F495 File Offset: 0x0016D695
			protected override void OnGameLoad()
			{
			}

			// Token: 0x060050A6 RID: 20646 RVA: 0x0016F497 File Offset: 0x0016D697
			protected override void HourlyTick()
			{
			}

			// Token: 0x060050A7 RID: 20647 RVA: 0x0016F499 File Offset: 0x0016D699
			protected override QuestBase GenerateIssueQuest(string questId)
			{
				return new LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssueQuest(questId, base.IssueOwner, this._youngHero);
			}

			// Token: 0x060050A8 RID: 20648 RVA: 0x0016F4AD File Offset: 0x0016D6AD
			public override IssueBase.IssueFrequency GetFrequency()
			{
				return IssueBase.IssueFrequency.Common;
			}

			// Token: 0x060050A9 RID: 20649 RVA: 0x0016F4B0 File Offset: 0x0016D6B0
			protected override bool CanPlayerTakeQuestConditions(Hero issueGiver, out IssueBase.PreconditionFlags flag, out Hero relationHero, out SkillObject skill)
			{
				relationHero = null;
				skill = null;
				flag = IssueBase.PreconditionFlags.None;
				if (issueGiver.GetRelationWithPlayer() < -10f)
				{
					flag |= IssueBase.PreconditionFlags.Relation;
					relationHero = issueGiver;
				}
				if (Hero.MainHero.IsKingdomLeader)
				{
					flag |= IssueBase.PreconditionFlags.MainHeroIsKingdomLeader;
				}
				if (issueGiver.MapFaction.IsAtWarWith(Hero.MainHero.MapFaction))
				{
					flag |= IssueBase.PreconditionFlags.AtWar;
				}
				if (Clan.PlayerClan.Tier < 2)
				{
					flag |= IssueBase.PreconditionFlags.ClanTier;
				}
				return flag == IssueBase.PreconditionFlags.None;
			}

			// Token: 0x060050AA RID: 20650 RVA: 0x0016F530 File Offset: 0x0016D730
			public override bool IssueStayAliveConditions()
			{
				return this._youngHero.Age >= 18f && this._youngHero.Age < 21f && this._youngHero.PartyBelongedTo == null && this._youngHero.PartyBelongedToAsPrisoner == null && this._youngHero.IsActive && this._youngHero.CurrentSettlement != null && this._youngHero.Level <= 20 && base.IssueOwner.Clan != Clan.PlayerClan && this._youngHero.Clan != Clan.PlayerClan && (this._youngHero.Spouse == null || this._youngHero.Children.IsEmpty<Hero>());
			}

			// Token: 0x060050AB RID: 20651 RVA: 0x0016F5EF File Offset: 0x0016D7EF
			protected override void CompleteIssueWithTimedOutConsequences()
			{
			}

			// Token: 0x04001A8A RID: 6794
			[SaveableField(1)]
			private Hero _youngHero;

			// Token: 0x04001A8B RID: 6795
			private const int MinimumRelationToTakeQuest = -10;
		}

		// Token: 0x02000651 RID: 1617
		public class LordsNeedsTutorIssueQuest : QuestBase
		{
			// Token: 0x060050AC RID: 20652 RVA: 0x0016F5F1 File Offset: 0x0016D7F1
			internal static void AutoGeneratedStaticCollectObjectsLordsNeedsTutorIssueQuest(object o, List<object> collectedObjects)
			{
				((LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssueQuest)o).AutoGeneratedInstanceCollectObjects(collectedObjects);
			}

			// Token: 0x060050AD RID: 20653 RVA: 0x0016F5FF File Offset: 0x0016D7FF
			protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
			{
				base.AutoGeneratedInstanceCollectObjects(collectedObjects);
				collectedObjects.Add(this._youngHero);
				collectedObjects.Add(this._oldSkillValues);
				collectedObjects.Add(this._startQuestLog);
			}

			// Token: 0x060050AE RID: 20654 RVA: 0x0016F62C File Offset: 0x0016D82C
			internal static object AutoGeneratedGetMemberValue_youngHero(object o)
			{
				return ((LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssueQuest)o)._youngHero;
			}

			// Token: 0x060050AF RID: 20655 RVA: 0x0016F639 File Offset: 0x0016D839
			internal static object AutoGeneratedGetMemberValue_checkForMissionEnd(object o)
			{
				return ((LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssueQuest)o)._checkForMissionEnd;
			}

			// Token: 0x060050B0 RID: 20656 RVA: 0x0016F64B File Offset: 0x0016D84B
			internal static object AutoGeneratedGetMemberValue_firstConversationInitialized(object o)
			{
				return ((LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssueQuest)o)._firstConversationInitialized;
			}

			// Token: 0x060050B1 RID: 20657 RVA: 0x0016F65D File Offset: 0x0016D85D
			internal static object AutoGeneratedGetMemberValue_questCompletedStartConversation(object o)
			{
				return ((LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssueQuest)o)._questCompletedStartConversation;
			}

			// Token: 0x060050B2 RID: 20658 RVA: 0x0016F66F File Offset: 0x0016D86F
			internal static object AutoGeneratedGetMemberValue_youngHeroBeginningSkillPoints(object o)
			{
				return ((LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssueQuest)o)._youngHeroBeginningSkillPoints;
			}

			// Token: 0x060050B3 RID: 20659 RVA: 0x0016F681 File Offset: 0x0016D881
			internal static object AutoGeneratedGetMemberValue_randomForQuestReward(object o)
			{
				return ((LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssueQuest)o)._randomForQuestReward;
			}

			// Token: 0x060050B4 RID: 20660 RVA: 0x0016F693 File Offset: 0x0016D893
			internal static object AutoGeneratedGetMemberValue_oldSkillValues(object o)
			{
				return ((LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssueQuest)o)._oldSkillValues;
			}

			// Token: 0x060050B5 RID: 20661 RVA: 0x0016F6A0 File Offset: 0x0016D8A0
			internal static object AutoGeneratedGetMemberValue_startQuestLog(object o)
			{
				return ((LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssueQuest)o)._startQuestLog;
			}

			// Token: 0x170010F3 RID: 4339
			// (get) Token: 0x060050B6 RID: 20662 RVA: 0x0016F6AD File Offset: 0x0016D8AD
			public override bool IsRemainingTimeHidden
			{
				get
				{
					return false;
				}
			}

			// Token: 0x170010F4 RID: 4340
			// (get) Token: 0x060050B7 RID: 20663 RVA: 0x0016F6B0 File Offset: 0x0016D8B0
			public override TextObject Title
			{
				get
				{
					TextObject textObject = new TextObject("{=XmGjTZz0}{?QUEST_GIVER.GENDER}Lady{?}Lord{\\?} Needs A Tutor", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x170010F5 RID: 4341
			// (get) Token: 0x060050B8 RID: 20664 RVA: 0x0016F6E4 File Offset: 0x0016D8E4
			private TextObject PlayerStartsQuestLogText
			{
				get
				{
					TextObject textObject = new TextObject("{=Celvao0J}{QUEST_GIVER.LINK} a {?QUEST_GIVER.GENDER}Lady{?}Lord{\\?} from {CLAN} clan has asked you to take a young clan member under your wings and train him for {DURATION} days. You have accepted to train him personally.", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					textObject.SetTextVariable("DURATION", 200);
					textObject.SetTextVariable("CLAN", base.QuestGiver.Clan.EncyclopediaLinkWithName);
					return textObject;
				}
			}

			// Token: 0x170010F6 RID: 4342
			// (get) Token: 0x060050B9 RID: 20665 RVA: 0x0016F744 File Offset: 0x0016D944
			private TextObject SuccessQuestLogText
			{
				get
				{
					TextObject textObject = new TextObject("{=j0QKnNqK}The training of {YOUNG_HERO.LINK} has been completed successfully. Both He and his clan is grateful to you.", null);
					StringHelpers.SetCharacterProperties("YOUNG_HERO", this._youngHero.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x170010F7 RID: 4343
			// (get) Token: 0x060050BA RID: 20666 RVA: 0x0016F778 File Offset: 0x0016D978
			private TextObject FailTimedOutQuestLogText
			{
				get
				{
					TextObject textObject = new TextObject("{=taz5cAtw}You failed to train the {YOUNG_HERO.LINK} enough as {QUEST_GIVER.LINK} expected. {?QUEST_GIVER.GENDER}She{?}He{\\?} is disappointed.", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					StringHelpers.SetCharacterProperties("YOUNG_HERO", this._youngHero.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x170010F8 RID: 4344
			// (get) Token: 0x060050BB RID: 20667 RVA: 0x0016F7C4 File Offset: 0x0016D9C4
			private TextObject PupilHasDiedLogText
			{
				get
				{
					TextObject textObject = new TextObject("{=abmSQFR5}{YOUNG_HERO.LINK} has died under your care. {QUEST_GIVER.LINK} is furious.", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					StringHelpers.SetCharacterProperties("YOUNG_HERO", this._youngHero.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x170010F9 RID: 4345
			// (get) Token: 0x060050BC RID: 20668 RVA: 0x0016F810 File Offset: 0x0016DA10
			private TextObject PupilEscapedLogText
			{
				get
				{
					TextObject textObject = new TextObject("{=dL8196qY}{YOUNG_HERO.LINK} has escaped. Find him to continue your quest.", null);
					StringHelpers.SetCharacterProperties("YOUNG_HERO", this._youngHero.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x170010FA RID: 4346
			// (get) Token: 0x060050BD RID: 20669 RVA: 0x0016F844 File Offset: 0x0016DA44
			private TextObject WarDeclaredQuestCancel
			{
				get
				{
					TextObject textObject = new TextObject("{=HkbK8cqw}Your clan is now at war with the {QUEST_GIVER.LINK}'s faction. Your agreement with {QUEST_GIVER.LINK} was terminated.", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x170010FB RID: 4347
			// (get) Token: 0x060050BE RID: 20670 RVA: 0x0016F878 File Offset: 0x0016DA78
			private TextObject PlayerDeclaredWarQuestLogText
			{
				get
				{
					TextObject textObject = new TextObject("{=bqeWVVEE}Your actions have started a war with {QUEST_GIVER.LINK}'s faction. {?QUEST_GIVER.GENDER}She{?}He{\\?} cancels your agreement and the quest is a failure.", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x170010FC RID: 4348
			// (get) Token: 0x060050BF RID: 20671 RVA: 0x0016F8AC File Offset: 0x0016DAAC
			private TextObject PlayerKickedYoungHeroFromClan
			{
				get
				{
					TextObject textObject = new TextObject("{=x3f1w3Gc}You have kicked {YOUNG_HERO.LINK} from your clan. Your agreement with {QUEST_GIVER.LINK} was terminated.", null);
					StringHelpers.SetCharacterProperties("YOUNG_HERO", this._youngHero.CharacterObject, textObject, false);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x170010FD RID: 4349
			// (get) Token: 0x060050C0 RID: 20672 RVA: 0x0016F8F8 File Offset: 0x0016DAF8
			private TextObject PlayerBecameClanLeader
			{
				get
				{
					TextObject textObject = new TextObject("{=JiD05yDw}{YOUNG_HERO.LINK} now becomes the leader of his clan and your agreement with {QUEST_GIVER.LINK} was terminated.", null);
					StringHelpers.SetCharacterProperties("YOUNG_HERO", this._youngHero.CharacterObject, textObject, false);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x170010FE RID: 4350
			// (get) Token: 0x060050C1 RID: 20673 RVA: 0x0016F944 File Offset: 0x0016DB44
			private TextObject PlayerMarriedYoungHero
			{
				get
				{
					TextObject textObject = new TextObject("{=QGigAhFW}You have married with {YOUNG_HERO.LINK} who is the young noble you agreed to be his tutor. {QUEST_GIVER.LINK} no longer expects you to tutor {YOUNG_HERO.LINK} and wishes you a joyful marriage.", null);
					StringHelpers.SetCharacterProperties("YOUNG_HERO", this._youngHero.CharacterObject, textObject, false);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x060050C2 RID: 20674 RVA: 0x0016F990 File Offset: 0x0016DB90
			public LordsNeedsTutorIssueQuest(string questId, Hero questGiver, Hero youngHero) : base(questId, questGiver, CampaignTime.DaysFromNow(200f), 0)
			{
				this._youngHero = youngHero;
				this._firstConversationInitialized = false;
				this._oldSkillValues = new Dictionary<SkillObject, int>();
				this._youngHero.SetHasMet();
				this._randomForQuestReward = MBRandom.RandomInt(2, 5);
				if (this._youngHero.GovernorOf != null)
				{
					ChangeGovernorAction.RemoveGovernorOf(this._youngHero);
				}
				this.SetDialogs();
				base.InitializeQuestOnCreation();
			}

			// Token: 0x060050C3 RID: 20675 RVA: 0x0016FA05 File Offset: 0x0016DC05
			protected override void InitializeQuestOnGameLoad()
			{
				this.SetDialogs();
				this._targetSkillGain = this._youngHeroBeginningSkillPoints + 30;
			}

			// Token: 0x060050C4 RID: 20676 RVA: 0x0016FA1C File Offset: 0x0016DC1C
			protected override void SetDialogs()
			{
				Campaign.Current.ConversationManager.AddDialogFlow(this.GetYoungHeroFirstDialogFlow(), this);
				Campaign.Current.ConversationManager.AddDialogFlow(this.GetYoungHeroSecondDialogFlow(), this);
				Campaign.Current.ConversationManager.AddDialogFlow(this.GetYoungHeroFailedDialogFlow(), this);
				this.OfferDialogFlow = DialogFlow.CreateDialogFlow("issue_classic_quest_start", 100).NpcLine(new TextObject("{=1WxrzNXx}He'll be delighted. I'll tell him to join you as soon as possible.", null), null, null).Condition(new ConversationSentence.OnConditionDelegate(this.NotableDialogCondition)).Consequence(new ConversationSentence.OnConsequenceDelegate(this.QuestAcceptedConsequences)).CloseDialog();
				this.DiscussDialogFlow = DialogFlow.CreateDialogFlow("quest_discuss", 100).NpcLine(new TextObject("{=OoNULWKy}How is the training going? Are you happy with your student?[if:convo_delighted][ib:hip]", null), null, null).Condition(new ConversationSentence.OnConditionDelegate(this.NotableDialogCondition)).Consequence(delegate
				{
					Campaign.Current.ConversationManager.ConversationEndOneShot += MapEventHelper.OnConversationEnd;
				}).BeginPlayerOptions().PlayerOption(new TextObject("{=jyxo4YgW}Yes, he is a promising boy.", null), null).NpcLine(new TextObject("{=QsL6qcDb}That's very good to hear! Thank you.[if:convo_merry]", null), null, null).CloseDialog().PlayerOption(new TextObject("{=SbbAhpTu}He is yet to prove himself actually.", null), null).NpcLine(new TextObject("{=aHid0t6n}Give him some chance I'm sure he will prove himself soon.", null), null, null).CloseDialog().EndPlayerOptions().CloseDialog();
			}

			// Token: 0x060050C5 RID: 20677 RVA: 0x0016FB6E File Offset: 0x0016DD6E
			private bool NotableDialogCondition()
			{
				StringHelpers.SetCharacterProperties("YOUNG_HERO", this._youngHero.CharacterObject, null, false);
				return Hero.OneToOneConversationHero == base.QuestGiver;
			}

			// Token: 0x060050C6 RID: 20678 RVA: 0x0016FB98 File Offset: 0x0016DD98
			private void QuestAcceptedConsequences()
			{
				base.StartQuest();
				AddCompanionAction.Apply(Clan.PlayerClan, this._youngHero);
				MobileParty.MainParty.MemberRoster.AddToCounts(this._youngHero.CharacterObject, 1, false, 0, 0, true, -1);
				this._youngHeroBeginningSkillPoints = this._youngHero.HeroDeveloper.GetTotalSkillPoints();
				this._targetSkillGain = this._youngHeroBeginningSkillPoints + 30;
				TextObject textObject = new TextObject("{=8GbGTDtL}{YOUNG_HERO.LINK}'s experience progress", null);
				StringHelpers.SetCharacterProperties("YOUNG_HERO", this._youngHero.CharacterObject, textObject, false);
				this._startQuestLog = base.AddDiscreteLog(this.PlayerStartsQuestLogText, textObject, this._youngHero.HeroDeveloper.GetTotalSkillPoints() - this._youngHeroBeginningSkillPoints, 30, null, false);
				this._checkForMissionEnd = true;
				foreach (SkillObject skillObject in Skills.All)
				{
					this._oldSkillValues.Add(skillObject, this._youngHero.GetSkillValue(skillObject));
					this._youngHero.HeroDeveloper.AddFocus(skillObject, 1, false);
				}
				LordsNeedsTutorIssueBehavior.SetAlreadyChosenHero(this._youngHero);
			}

			// Token: 0x060050C7 RID: 20679 RVA: 0x0016FCD0 File Offset: 0x0016DED0
			protected override void RegisterEvents()
			{
				CampaignEvents.HeroKilledEvent.AddNonSerializedListener(this, new Action<Hero, Hero, KillCharacterAction.KillCharacterActionDetail, bool>(this.OnHeroKilled));
				CampaignEvents.HeroPrisonerTaken.AddNonSerializedListener(this, new Action<PartyBase, Hero>(this.OnPrisonerTaken));
				CampaignEvents.HeroGainedSkill.AddNonSerializedListener(this, new Action<Hero, SkillObject, int, bool>(this.OnHeroGainedSkill));
				CampaignEvents.WarDeclared.AddNonSerializedListener(this, new Action<IFaction, IFaction, DeclareWarAction.DeclareWarDetail>(this.OnWarDeclared));
				CampaignEvents.OnClanLeaderChangedEvent.AddNonSerializedListener(this, new Action<Hero, Hero>(this.OnClanLeaderChanged));
				CampaignEvents.OnClanChangedKingdomEvent.AddNonSerializedListener(this, new Action<Clan, Kingdom, Kingdom, ChangeKingdomAction.ChangeKingdomActionDetail, bool>(this.OnClanChangedKingdom));
				CampaignEvents.CompanionRemoved.AddNonSerializedListener(this, new Action<Hero, RemoveCompanionAction.RemoveCompanionDetail>(this.OnCompanionRemoved));
				CampaignEvents.HeroesMarried.AddNonSerializedListener(this, new Action<Hero, Hero, bool>(this.OnHeroesMarried));
				CampaignEvents.MapEventStarted.AddNonSerializedListener(this, new Action<MapEvent, PartyBase, PartyBase>(this.OnMapEventStarted));
				CampaignEvents.SettlementEntered.AddNonSerializedListener(this, new Action<MobileParty, Settlement, Hero>(this.OnSettlementEntered));
				CampaignEvents.OnGameLoadFinishedEvent.AddNonSerializedListener(this, new Action(this.OnGameLoadFinished));
			}

			// Token: 0x060050C8 RID: 20680 RVA: 0x0016FDDA File Offset: 0x0016DFDA
			private void OnGameLoadFinished()
			{
				if (Settlement.CurrentSettlement != null && Settlement.CurrentSettlement.HeroesWithoutParty.Contains(this._youngHero))
				{
					this.SpawnYoungHeroInLordsHall();
				}
			}

			// Token: 0x060050C9 RID: 20681 RVA: 0x0016FE00 File Offset: 0x0016E000
			private void OnSettlementEntered(MobileParty party, Settlement settlement, Hero hero)
			{
				if (party != null && party.IsMainParty && settlement.HeroesWithoutParty.Contains(this._youngHero))
				{
					this.SpawnYoungHeroInLordsHall();
				}
			}

			// Token: 0x060050CA RID: 20682 RVA: 0x0016FE26 File Offset: 0x0016E026
			public override void OnHeroCanBeSelectedInInventoryInfoIsRequested(Hero hero, ref bool result)
			{
				this.CommonRestrictionInfoIsRequested(hero, ref result);
			}

			// Token: 0x060050CB RID: 20683 RVA: 0x0016FE30 File Offset: 0x0016E030
			public override void OnHeroCanHavePartyRoleOrBeGovernorInfoIsRequested(Hero hero, ref bool result)
			{
				this.CommonRestrictionInfoIsRequested(hero, ref result);
			}

			// Token: 0x060050CC RID: 20684 RVA: 0x0016FE3A File Offset: 0x0016E03A
			public override void OnHeroCanLeadPartyInfoIsRequested(Hero hero, ref bool result)
			{
				this.CommonRestrictionInfoIsRequested(hero, ref result);
			}

			// Token: 0x060050CD RID: 20685 RVA: 0x0016FE44 File Offset: 0x0016E044
			public override void OnHeroCanHaveQuestOrIssueInfoIsRequested(Hero hero, ref bool result)
			{
				this.CommonRestrictionInfoIsRequested(hero, ref result);
			}

			// Token: 0x060050CE RID: 20686 RVA: 0x0016FE4E File Offset: 0x0016E04E
			public override void OnHeroCanMarryInfoIsRequested(Hero hero, ref bool result)
			{
				this.CommonRestrictionInfoIsRequested(hero, ref result);
			}

			// Token: 0x060050CF RID: 20687 RVA: 0x0016FE58 File Offset: 0x0016E058
			private void CommonRestrictionInfoIsRequested(Hero hero, ref bool result)
			{
				if (hero == this._youngHero)
				{
					result = false;
				}
			}

			// Token: 0x060050D0 RID: 20688 RVA: 0x0016FE66 File Offset: 0x0016E066
			private void OnMapEventStarted(MapEvent mapEvent, PartyBase attackerParty, PartyBase defenderParty)
			{
				if (QuestHelper.CheckMinorMajorCoercion(this, mapEvent, attackerParty))
				{
					QuestHelper.ApplyGenericMinorMajorCoercionConsequences(this, mapEvent);
				}
			}

			// Token: 0x060050D1 RID: 20689 RVA: 0x0016FE79 File Offset: 0x0016E079
			private void OnHeroesMarried(Hero hero1, Hero hero2, bool showNotification = true)
			{
				if ((hero1 == Hero.MainHero && hero2 == this._youngHero) || (hero2 == Hero.MainHero && hero1 == this._youngHero))
				{
					this._doNotForceYoungHeroOutFromClan = true;
					base.CompleteQuestWithCancel(this.PlayerMarriedYoungHero);
				}
			}

			// Token: 0x060050D2 RID: 20690 RVA: 0x0016FEB0 File Offset: 0x0016E0B0
			private void OnClanLeaderChanged(Hero oldLeader, Hero newLeader)
			{
				if (base.IsOngoing && newLeader == this._youngHero)
				{
					base.AddLog(this.PlayerBecameClanLeader, false);
					base.CompleteQuestWithFail(null);
				}
			}

			// Token: 0x060050D3 RID: 20691 RVA: 0x0016FED8 File Offset: 0x0016E0D8
			private void OnCompanionRemoved(Hero companion, RemoveCompanionAction.RemoveCompanionDetail detail)
			{
				if (base.IsOngoing && companion == this._youngHero)
				{
					base.AddLog(this.PlayerKickedYoungHeroFromClan, false);
					base.CompleteQuestWithFail(null);
				}
			}

			// Token: 0x060050D4 RID: 20692 RVA: 0x0016FF00 File Offset: 0x0016E100
			private void OnClanChangedKingdom(Clan clan, Kingdom oldKingdom, Kingdom newKingdom, ChangeKingdomAction.ChangeKingdomActionDetail detail, bool showNotification = true)
			{
				if (base.QuestGiver.MapFaction.IsAtWarWith(Hero.MainHero.MapFaction))
				{
					base.CompleteQuestWithCancel(this.WarDeclaredQuestCancel);
				}
			}

			// Token: 0x060050D5 RID: 20693 RVA: 0x0016FF2A File Offset: 0x0016E12A
			private void OnWarDeclared(IFaction faction1, IFaction faction2, DeclareWarAction.DeclareWarDetail detail)
			{
				QuestHelper.CheckWarDeclarationAndFailOrCancelTheQuest(this, faction1, faction2, detail, this.PlayerDeclaredWarQuestLogText, this.WarDeclaredQuestCancel, false);
			}

			// Token: 0x060050D6 RID: 20694 RVA: 0x0016FF44 File Offset: 0x0016E144
			public void OnHeroGainedSkill(Hero hero, SkillObject skill, int change = 1, bool shouldNotify = true)
			{
				if (hero == this._youngHero)
				{
					int progress = MBMath.ClampInt(this._youngHero.HeroDeveloper.GetTotalSkillPoints() - this._youngHeroBeginningSkillPoints, 0, 30);
					this._startQuestLog.UpdateCurrentProgress(progress);
					if (this._youngHero.HeroDeveloper.GetTotalSkillPoints() >= this._targetSkillGain)
					{
						this._questCompletedStartConversation = true;
					}
				}
			}

			// Token: 0x060050D7 RID: 20695 RVA: 0x0016FFA8 File Offset: 0x0016E1A8
			private void OnPrisonerTaken(PartyBase capturer, Hero prisoner)
			{
				if (prisoner == Hero.MainHero && this._youngHero.IsPlayerCompanion && MobileParty.MainParty.MapEventSide != null)
				{
					if (MobileParty.MainParty.MapEventSide.Parties.First((MapEventParty x) => x.Party == PartyBase.MainParty).Troops.FindIndexOfCharacter(this._youngHero.CharacterObject).IsValid)
					{
						base.AddLog(this.PupilEscapedLogText, false);
						EndCaptivityAction.ApplyByEscape(this._youngHero, null);
					}
				}
			}

			// Token: 0x060050D8 RID: 20696 RVA: 0x00170045 File Offset: 0x0016E245
			private void OnHeroKilled(Hero victim, Hero killer, KillCharacterAction.KillCharacterActionDetail detail, bool showNotification = true)
			{
				if (victim == this._youngHero)
				{
					base.AddLog(this.PupilHasDiedLogText, false);
					this.RelationshipChangeWithQuestGiver = -40;
					base.CompleteQuestWithFail(null);
				}
			}

			// Token: 0x060050D9 RID: 20697 RVA: 0x00170070 File Offset: 0x0016E270
			protected override void HourlyTick()
			{
				if (base.IsOngoing && !Hero.MainHero.IsPrisoner && Settlement.CurrentSettlement == null && PlayerEncounter.Current == null && MapEvent.PlayerMapEvent == null && this._youngHero.PartyBelongedTo == MobileParty.MainParty && GameStateManager.Current.ActiveState is MapState && ((this._checkForMissionEnd && !this._firstConversationInitialized) || this._questCompletedStartConversation))
				{
					CampaignMapConversation.OpenConversation(new ConversationCharacterData(CharacterObject.PlayerCharacter, PartyBase.MainParty, false, false, false, false, false, false), new ConversationCharacterData(this._youngHero.CharacterObject, PartyBase.MainParty, false, false, false, false, false, false));
					if (this._checkForMissionEnd)
					{
						this._checkForMissionEnd = false;
					}
				}
			}

			// Token: 0x060050DA RID: 20698 RVA: 0x00170134 File Offset: 0x0016E334
			private void SpawnYoungHeroInLordsHall()
			{
				Monster monsterWithSuffix = FaceGen.GetMonsterWithSuffix(this._youngHero.CharacterObject.Race, "_settlement");
				ValueTuple<string, Monster> valueTuple = new ValueTuple<string, Monster>(ActionSetCode.GenerateActionSetNameWithSuffix(monsterWithSuffix, this._youngHero.CharacterObject.IsFemale, "_lord"), monsterWithSuffix);
				IFaction mapFaction = this._youngHero.MapFaction;
				uint color = (mapFaction != null) ? mapFaction.Color : 4291609515U;
				IFaction mapFaction2 = this._youngHero.MapFaction;
				uint color2 = (mapFaction2 != null) ? mapFaction2.Color : 4291609515U;
				AgentData agentData = new AgentData(new SimpleAgentOrigin(this._youngHero.CharacterObject, -1, null, default(UniqueTroopDescriptor))).Monster(valueTuple.Item2).NoHorses(true).ClothingColor1(color).ClothingColor2(color2);
				LocationComplex.Current.GetLocationWithId("lordshall").AddCharacter(new LocationCharacter(agentData, new LocationCharacter.AddBehaviorsDelegate(SandBoxManager.Instance.AgentBehaviorManager.AddFixedCharacterBehaviors), "sp_notable", true, LocationCharacter.CharacterRelations.Neutral, valueTuple.Item1, true, false, null, false, false, true));
			}

			// Token: 0x060050DB RID: 20699 RVA: 0x0017023C File Offset: 0x0016E43C
			private DialogFlow GetYoungHeroFirstDialogFlow()
			{
				return DialogFlow.CreateDialogFlow("start", 125).NpcLine(new TextObject("{=XH66Leg5}Greetings, my {?PLAYER.GENDER}lady{?}lord{\\?}. I have heard much of your deeds. Thank you for agreeing to train me. I hope I won't disappoint you.[if:convo_grateful][ib:demure]", null), null, null).Condition(() => Hero.OneToOneConversationHero == this._youngHero && !this._firstConversationInitialized).Consequence(delegate
				{
					Campaign.Current.ConversationManager.ConversationEndOneShot += this.FirstConversationEndConsequence;
				}).BeginPlayerOptions().PlayerOption(new TextObject("{=oJJiKTSL}You are welcome.", null), null).NpcLine(new TextObject("{=wlKtDR2z}Thank you, {?PLAYER.GENDER}my lady{?}sir{\\?}.", null), null, null).CloseDialog().PlayerOption(new TextObject("{=FHeJ8bsX}We will see about that.", null), null).NpcLine(new TextObject("{=kc3RfwFb}I'll try to be useful to you, {?PLAYER.GENDER}my lady{?}sir{\\?}.", null), null, null).EndPlayerOptions().PlayerLine(new TextObject("{=kJwpbptU}Well, try to stay close to me at all times and try to learn as much as you can.", null), null).NpcLine(new TextObject("{=EaifHOao}Yes, {?PLAYER.GENDER}my lady{?}sir{\\?}, I will.", null), null, null).CloseDialog();
			}

			// Token: 0x060050DC RID: 20700 RVA: 0x00170306 File Offset: 0x0016E506
			private DialogFlow GetYoungHeroFailedDialogFlow()
			{
				return DialogFlow.CreateDialogFlow("start", 125).NpcLine(new TextObject("{=vbbc6sIU}I regret to tell you that my progress under your tutelage is not satisfactory. I should return to my clan to resume my studies. Thank you for your trouble anyway.", null), null, null).Condition(() => Hero.OneToOneConversationHero == this._youngHero && this._showQuestFailedConversation).CloseDialog();
			}

			// Token: 0x060050DD RID: 20701 RVA: 0x0017033C File Offset: 0x0016E53C
			private void FirstConversationEndConsequence()
			{
				this._youngHero.SetHasMet();
				this._firstConversationInitialized = true;
			}

			// Token: 0x060050DE RID: 20702 RVA: 0x00170350 File Offset: 0x0016E550
			private DialogFlow GetYoungHeroSecondDialogFlow()
			{
				return DialogFlow.CreateDialogFlow("start", 125).BeginNpcOptions().NpcOption(new TextObject("{=APEBfqyW}Greetings my {?PLAYER.GENDER}lady{?}lord{\\?}. Do you wish something from me?[if:convo_innocent_smile][ib:normal2]", null), new ConversationSentence.OnConditionDelegate(this.default_conversation_with_young_hero_condition), null, null).BeginPlayerOptions().PlayerOption(new TextObject("{=BO0f1Klt}So - how do you find life in our company? Is it all you expected?.", null), null).NpcLine(new TextObject("{=e3e79n9B}It is all I expected and more, captain. I am glad that you took me with you.[if:convo_grateful][ib:normal2]", null), null, null).PlayerLine(new TextObject("{=dbG3PGXL}I'm glad you think that way. Combat aside, have you learned anything special?", null), null).NpcLine(new TextObject("{=8L9W34D6}{NPC_EXPERIENCE_LINE}", null), null, null).Condition(new ConversationSentence.OnConditionDelegate(this.npc_experience_line_condition)).PlayerLine(new TextObject("{=Rh0DlvvE}I'm glad you see it that way. Go on. Continue your training.", null), null).NpcLine(new TextObject("{=dnvPDnzS}I will, my {?PLAYER.GENDER}lady{?}lord{\\?}. Thank you[if:convo_grateful][ib:demure]", null), null, null).CloseDialog().PlayerOption(new TextObject("{=Lk6ln3sR}We seem to have got separated but I have found you. Join me, as we need to continue your training.", null), null).Condition(new ConversationSentence.OnConditionDelegate(this.PupilJoinMeCondition)).NpcLine(new TextObject("{=0coOJAvg}Yes, {?PLAYER.GENDER}madam{?}sir{\\?}. Thank you.", null), null, null).Consequence(delegate
				{
					MobileParty.MainParty.MemberRoster.AddToCounts(this._youngHero.CharacterObject, 1, false, 0, 0, true, -1);
				}).CloseDialog().EndPlayerOptions().NpcOption(new TextObject("{=kUbovNbE}My {?PLAYER.GENDER}lady{?}lord{\\?}. The agreed training time with you is over. I thank you for everything. It's been a very productive for me.[if:convo_delighted][ib:demure]", null), new ConversationSentence.OnConditionDelegate(this.quest_finished_conversation_with_young_hero_condition), null, null).PlayerLine(new TextObject("{=bS0bBgp3}I'm happy to hear this. Tell me, what is the most important lesson you've learned from me?", null), null).NpcLine(new TextObject("{=8L9W34D6}{NPC_EXPERIENCE_LINE}", null), null, null).Condition(new ConversationSentence.OnConditionDelegate(this.npc_experience_line_condition)).PlayerLine(new TextObject("{=orprhyYl}I'm glad you see it that way. Very well then, off you go. Send my regards to your family. I hope to see you again one day. I am sure you will make an excellent commander.", null), null).NpcLine(new TextObject("{=IBXfCLMp}I certainly hope too {?PLAYER.GENDER}lady{?}lord{\\?}! Again, I want to thank you for everything, before I go, please accept this gift as a humble gratitude.[if:convo_calm_friendly]", null), null, null).Consequence(new ConversationSentence.OnConsequenceDelegate(this.QuestCompletedWithSuccessAfterConversation)).CloseDialog().EndNpcOptions();
			}

			// Token: 0x060050DF RID: 20703 RVA: 0x001704EF File Offset: 0x0016E6EF
			private bool PupilJoinMeCondition()
			{
				return MobileParty.MainParty.MemberRoster.GetTroopRoster().All((TroopRosterElement x) => x.Character != this._youngHero.CharacterObject);
			}

			// Token: 0x060050E0 RID: 20704 RVA: 0x00170514 File Offset: 0x0016E714
			private void QuestCompletedWithSuccessAfterConversation()
			{
				this.RelationshipChangeWithQuestGiver = 25;
				ChangeRelationAction.ApplyPlayerRelation(this._youngHero, 15, true, true);
				base.CompleteQuestWithSuccess();
				base.AddLog(this.SuccessQuestLogText, false);
				ItemObject randomElementWithPredicate = Items.All.GetRandomElementWithPredicate((ItemObject x) => x.IsTradeGood && x.ItemCategory == DefaultItemCategories.Jewelry);
				TextObject textObject = new TextObject("{=lWvuM5aj}{GIFT_NUMBER} pieces of {JEWELRY} have been added to your inventory.", null);
				textObject.SetTextVariable("GIFT_NUMBER", this._randomForQuestReward);
				textObject.SetTextVariable("JEWELRY", randomElementWithPredicate.Name);
				MBInformationManager.AddQuickInformation(textObject, 0, null, "");
				MobileParty.MainParty.ItemRoster.AddToCounts(randomElementWithPredicate, this._randomForQuestReward);
				GainRenownAction.Apply(Hero.MainHero, 5f, false);
			}

			// Token: 0x060050E1 RID: 20705 RVA: 0x001705D8 File Offset: 0x0016E7D8
			private bool npc_experience_line_condition()
			{
				List<KeyValuePair<LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssueQuest.ExperienceIncreaseCondition, TextObject>> list = new List<KeyValuePair<LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssueQuest.ExperienceIncreaseCondition, TextObject>>();
				list.Add(new KeyValuePair<LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssueQuest.ExperienceIncreaseCondition, TextObject>(new LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssueQuest.ExperienceIncreaseCondition(this.strength_increased_condition), new TextObject("{=hMiJvlJ5}Yes, Since we last spoke, I've learned a lot about hand-to-hand combat, my {?PLAYER.GENDER}lady{?}lord{\\?}. Correct timing and putting your whole body behind the blow means a lot more than I initially thought.[if:convo_calm_friendly][ib:warrior]", null)));
				list.Add(new KeyValuePair<LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssueQuest.ExperienceIncreaseCondition, TextObject>(new LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssueQuest.ExperienceIncreaseCondition(this.perception_increased_condition), new TextObject("{=TrQzYwVD}Yes, {?PLAYER.GENDER}my lady{?}lord{\\?}. Since we last spoke I had chance to increase my understanding of ranged combat. How to breath, calculate distance, and lead the target if necessary.[if:convo_calm_friendly][ib:normal]", null)));
				list.Add(new KeyValuePair<LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssueQuest.ExperienceIncreaseCondition, TextObject>(new LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssueQuest.ExperienceIncreaseCondition(this.endurance_increased_condition), new TextObject("{=XF7shG4k}Since we last spoke I've been training vigorously. I feel tougher, much more energetic and alive now.[if:convo_calm_friendly][ib:warrior2]", null)));
				list.Add(new KeyValuePair<LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssueQuest.ExperienceIncreaseCondition, TextObject>(new LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssueQuest.ExperienceIncreaseCondition(this.cunning_increased_condition), new TextObject("{=H6l9cm7I}I've been paying attention to your subtler methods, {?PLAYER.GENDER}my lady{?}lord{\\?}, I've been observing that courage and strength in numbers is not enough to win most engagements. You have to be aware of the situation and seize the opportunities when they present themselves.[if:convo_calm_friendly][ib:hip]", null)));
				list.Add(new KeyValuePair<LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssueQuest.ExperienceIncreaseCondition, TextObject>(new LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssueQuest.ExperienceIncreaseCondition(this.social_increased_condition), new TextObject("{=bNAbWn4E}I've been watching how you deal with different kinds of folk: how to present yourself, how to address people from various walks of life properly, how to inspire greatness to those who trust in you.[if:convo_calm_friendly][ib:confident]", null)));
				list.Add(new KeyValuePair<LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssueQuest.ExperienceIncreaseCondition, TextObject>(new LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssueQuest.ExperienceIncreaseCondition(this.intelligence_increased_condition), new TextObject("{=9bd0jJD8}I've been studying a lot, {?PLAYER.GENDER}my lady{?}lord{\\?}. The manuscripts I've acquired on the way on various subjects are invaluable. Seeing professionals in action complements the theoretical knowledge I've learned from the manuscripts.[if:convo_calm_friendly][ib:demure2]", null)));
				MBList<TextObject> mblist = new MBList<TextObject>();
				foreach (KeyValuePair<LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssueQuest.ExperienceIncreaseCondition, TextObject> keyValuePair in list)
				{
					if (keyValuePair.Key())
					{
						mblist.Add(keyValuePair.Value);
					}
				}
				if (mblist.Count != 0)
				{
					MBTextManager.SetTextVariable("NPC_EXPERIENCE_LINE", mblist.GetRandomElement<TextObject>(), false);
					return true;
				}
				MBTextManager.SetTextVariable("NPC_EXPERIENCE_LINE", new TextObject("{=XFafAocV}Nothing specific, captain. But I'm paying close attention to everything you do.[if:convo_excited][ib:nervous]", null), false);
				return true;
			}

			// Token: 0x060050E2 RID: 20706 RVA: 0x00170744 File Offset: 0x0016E944
			private bool default_conversation_with_young_hero_condition()
			{
				return Hero.OneToOneConversationHero == this._youngHero && this._firstConversationInitialized && !this._questCompletedStartConversation && !this._showQuestFailedConversation;
			}

			// Token: 0x060050E3 RID: 20707 RVA: 0x0017076E File Offset: 0x0016E96E
			private bool quest_finished_conversation_with_young_hero_condition()
			{
				return Hero.OneToOneConversationHero == this._youngHero && this._firstConversationInitialized && this._questCompletedStartConversation && !this._showQuestFailedConversation;
			}

			// Token: 0x060050E4 RID: 20708 RVA: 0x00170798 File Offset: 0x0016E998
			private bool strength_increased_condition()
			{
				int num = 0;
				foreach (KeyValuePair<SkillObject, int> keyValuePair in this._oldSkillValues)
				{
					if (keyValuePair.Key.CharacterAttribute == DefaultCharacterAttributes.Vigor)
					{
						num += this._youngHero.GetSkillValue(keyValuePair.Key) - keyValuePair.Value;
					}
				}
				return num > 15;
			}

			// Token: 0x060050E5 RID: 20709 RVA: 0x0017081C File Offset: 0x0016EA1C
			private bool perception_increased_condition()
			{
				int num = 0;
				foreach (KeyValuePair<SkillObject, int> keyValuePair in this._oldSkillValues)
				{
					if (keyValuePair.Key.CharacterAttribute == DefaultCharacterAttributes.Control)
					{
						num += this._youngHero.GetSkillValue(keyValuePair.Key) - keyValuePair.Value;
					}
				}
				return num > 15;
			}

			// Token: 0x060050E6 RID: 20710 RVA: 0x001708A0 File Offset: 0x0016EAA0
			private bool endurance_increased_condition()
			{
				int num = 0;
				foreach (KeyValuePair<SkillObject, int> keyValuePair in this._oldSkillValues)
				{
					if (keyValuePair.Key.CharacterAttribute == DefaultCharacterAttributes.Endurance)
					{
						num += this._youngHero.GetSkillValue(keyValuePair.Key) - keyValuePair.Value;
					}
				}
				return num > 15;
			}

			// Token: 0x060050E7 RID: 20711 RVA: 0x00170924 File Offset: 0x0016EB24
			private bool cunning_increased_condition()
			{
				int num = 0;
				foreach (KeyValuePair<SkillObject, int> keyValuePair in this._oldSkillValues)
				{
					if (keyValuePair.Key.CharacterAttribute == DefaultCharacterAttributes.Cunning)
					{
						num += this._youngHero.GetSkillValue(keyValuePair.Key) - keyValuePair.Value;
					}
				}
				return num > 15;
			}

			// Token: 0x060050E8 RID: 20712 RVA: 0x001709A8 File Offset: 0x0016EBA8
			private bool social_increased_condition()
			{
				int num = 0;
				foreach (KeyValuePair<SkillObject, int> keyValuePair in this._oldSkillValues)
				{
					if (keyValuePair.Key.CharacterAttribute == DefaultCharacterAttributes.Social)
					{
						num += this._youngHero.GetSkillValue(keyValuePair.Key) - keyValuePair.Value;
					}
				}
				return num > 15;
			}

			// Token: 0x060050E9 RID: 20713 RVA: 0x00170A2C File Offset: 0x0016EC2C
			private bool intelligence_increased_condition()
			{
				int num = 0;
				foreach (KeyValuePair<SkillObject, int> keyValuePair in this._oldSkillValues)
				{
					if (keyValuePair.Key.CharacterAttribute == DefaultCharacterAttributes.Intelligence)
					{
						num += this._youngHero.GetSkillValue(keyValuePair.Key) - keyValuePair.Value;
					}
				}
				return num > 15;
			}

			// Token: 0x060050EA RID: 20714 RVA: 0x00170AB0 File Offset: 0x0016ECB0
			protected override void OnFinalize()
			{
				if (this._youngHero.IsAlive)
				{
					if (this._youngHero.CompanionOf == Clan.PlayerClan)
					{
						RemoveCompanionAction.ApplyAfterQuest(Clan.PlayerClan, this._youngHero);
						if (!this._doNotForceYoungHeroOutFromClan)
						{
							this._youngHero.Clan = base.QuestGiver.Clan;
						}
						foreach (Hero hero in this._youngHero.Children)
						{
							hero.Clan = this._youngHero.Clan;
						}
						if (this._youngHero.Spouse != null)
						{
							this._youngHero.Spouse.Clan = this._youngHero.Clan;
						}
					}
					foreach (SkillObject skill in Skills.All)
					{
						this._youngHero.HeroDeveloper.AddFocus(skill, -1, false);
					}
				}
			}

			// Token: 0x060050EB RID: 20715 RVA: 0x00170BD8 File Offset: 0x0016EDD8
			protected override void OnCompleteWithSuccess()
			{
			}

			// Token: 0x060050EC RID: 20716 RVA: 0x00170BDC File Offset: 0x0016EDDC
			protected override void OnTimedOut()
			{
				base.AddLog(this.FailTimedOutQuestLogText, false);
				this.RelationshipChangeWithQuestGiver = -10;
				this._showQuestFailedConversation = true;
				if (Settlement.CurrentSettlement == null && PlayerEncounter.Current == null && MapEvent.PlayerMapEvent == null && GameStateManager.Current.ActiveState is MapState)
				{
					CampaignMapConversation.OpenConversation(new ConversationCharacterData(CharacterObject.PlayerCharacter, PartyBase.MainParty, false, false, false, false, false, false), new ConversationCharacterData(this._youngHero.CharacterObject, PartyBase.MainParty, false, false, false, false, false, false));
				}
			}

			// Token: 0x04001A8C RID: 6796
			private const int MinimumSkillGainToComment = 15;

			// Token: 0x04001A8D RID: 6797
			private const int TargetSkillPointDelta = 30;

			// Token: 0x04001A8E RID: 6798
			[SaveableField(10)]
			private Hero _youngHero;

			// Token: 0x04001A8F RID: 6799
			[SaveableField(20)]
			private bool _checkForMissionEnd;

			// Token: 0x04001A90 RID: 6800
			[SaveableField(30)]
			private bool _firstConversationInitialized;

			// Token: 0x04001A91 RID: 6801
			[SaveableField(40)]
			private bool _questCompletedStartConversation;

			// Token: 0x04001A92 RID: 6802
			[SaveableField(50)]
			private int _youngHeroBeginningSkillPoints;

			// Token: 0x04001A93 RID: 6803
			[SaveableField(60)]
			private int _randomForQuestReward;

			// Token: 0x04001A94 RID: 6804
			private int _targetSkillGain;

			// Token: 0x04001A95 RID: 6805
			[SaveableField(70)]
			private Dictionary<SkillObject, int> _oldSkillValues;

			// Token: 0x04001A96 RID: 6806
			private bool _doNotForceYoungHeroOutFromClan;

			// Token: 0x04001A97 RID: 6807
			private bool _showQuestFailedConversation;

			// Token: 0x04001A98 RID: 6808
			[SaveableField(80)]
			private JournalLog _startQuestLog;

			// Token: 0x020007BF RID: 1983
			// (Invoke) Token: 0x06005B02 RID: 23298
			private delegate bool ExperienceIncreaseCondition();
		}

		// Token: 0x02000652 RID: 1618
		public class LordsNeedsTutorIssueTypeDefiner : SaveableTypeDefiner
		{
			// Token: 0x060050F2 RID: 20722 RVA: 0x00170CEA File Offset: 0x0016EEEA
			public LordsNeedsTutorIssueTypeDefiner() : base(80120)
			{
			}

			// Token: 0x060050F3 RID: 20723 RVA: 0x00170CF7 File Offset: 0x0016EEF7
			protected override void DefineClassTypes()
			{
				base.AddClassDefinition(typeof(LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssue), 1, null);
				base.AddClassDefinition(typeof(LordsNeedsTutorIssueBehavior.LordsNeedsTutorIssueQuest), 2, null);
			}
		}
	}
}
